<template>
  <div>
    <el-form :model="formInline" label-width="80px">
      <el-form-item label="用户名">
        <el-input v-model.trim="formInline.Name" placeholder="用户名"></el-input>
      </el-form-item>
      <el-form-item label="描述">
        <el-input v-model="formInline.Description" placeholder="描述"></el-input>
      </el-form-item>
      <el-form-item label="排序">
        <el-input v-model.number="formInline.Sort" placeholder="排序"></el-input>
      </el-form-item>
      <el-form-item class="editdata_button">
       <el-button type="primary" @click="EditSubmit">保存</el-button>
        <el-button type="default" @click="EditCancle">取消</el-button>
        <el-button type="warning" @click="EditClear">默认</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
import {mixinEditMixed} from '@/mixedObject/editMixed'
export default {
    mixins:[mixinEditMixed],
  props: ["currentId", "random"],
  data() {
    return {
     
    };
  },
  watch: {
    random(newValue, oldValue) {
      //初始化表单
      this.InitFormInLine();
    }
  },
  created() {
       //初始化表单
      this.InitFormInLine();
  },
  methods: {
    //初始化
    InitFormInLine() {
      this.$store
        .dispatch("role/GetRoleInfo", {Id:this.currentId})
        .then(data => {
          this.formInline = {
            Id:this.currentId,
            Name: data.name,
            Description: data.description,
            Sort: data.sort,
            TypeOper: "1"
          };
        });
    },
    //保存
    EditSubmit() {
      this.$store
        .dispatch("role/AddEditRoleInfo", this.formInline)
        .then(data => {
          //回调事件
          this.$emit("SuccessReturn", { type: "edit", isSelect: true });
        });
    },

  }
};
</script>